<!--展示个人名片-->
<template>
  <div style="box-sizing: border-box">

  </div>
</template>

<script>
export default {
  name: "WorkersView",
  data() {
    return {
      options: [{value: '选项1', label: '找工人'}, {value: '选项2', label: '找活干'}], value: '',
      clearable: [
        {value: '全国', label: '全国',},
        {
          value: 1, label: '贵州',
          children: [
            {value: '选项1', label: '全部'},
            {value: '选项2', label: '贵阳'},
            {value: '选项3', label: '安顺'},
            {value: '选项4', label: '毕节'}
          ]
        },
        {
          value: 2, label: '北京',
          children: [
            {value: '选项0', label: '全部'},
            {value: '选项1', label: '东城区'},
            {value: '选项2', label: '西城区'},
            {value: '选项3', label: '海定区'},
            {value: '选项4', label: '朝阳区'}
          ]
        },],
      ages: ['不限', '18-25岁', '26-35岁', '36-45岁', '45岁+'],
      selectedAges: [],
      demand: ['不限', '实名认证', '技能证书', '项目经验', '找活视频'],
      selectedDemand: [],
      pay: ['不限', '日结', '月结', '计量', '面议'],
      selectedpay: [],
      proficiency: ['不限', '小工', '中工', '大工'],
      selectedproficiency: [],
      term: ['不限', '长期工', '短期工', '长短皆可'],
      selectedterm: [],
      wd: '',
      user:'',
      businessTemp:[],
      business: [{
        username: "",
        imgUrl:"",
        proficiency:"",
        salary:"",
        gender: "",
        age: "",
        nation: "",
        seniority: "",
        findId:"",
        list:[],
        selfInfo:"",
        disworkName:"",
        predistName:"",
        indetail:"",
        term:""
      }],
      selectedOptions: ""
    }

  },
  methods: {
    inputReager(id){

      let jwt=this.user.token;
      this.axios
          .create({
            'headers': {
              'Authorization': jwt
            }
          })
          .get('http://localhost:29000/v1/workers/'+id+'/bussine')
      .then((response)=>{
        if (response.data.code==20000){
          alert(response.data.data.phone)
        }else{
          this.$message.error(response.data.message);
        }
      })
    },
    detail(id){
      this.$router.push('/detail?id='+id);
    },
    search() {
      // let wd = new URLSearchParams(location.search).get('wd');
      if (this.wd!=""){
        this.axios.get('http://localhost:19470/v1/workers/' + this.wd + '/search')
            .then((response)=>{
              if (response.data.code == 1) {
                let butemp= response.data.data;
                for (let i=0;i<butemp.length;i++) {
                  if (butemp[i].gender==true){
                    butemp[i].gender='男'
                  }else{
                    butemp[i].gender='女'
                  }
                  if (butemp[i].findId==true){
                    butemp[i].findId='找活中';
                  }else{
                    butemp[i].findId='已找到';
                  }
                }
                this.business=butemp;
              }
            })
      }else{
        this.handleChange();
      }
    },
    reg() {
      if (this.$route.path != '/reg') {
        this.$router.push('/reg')
      }
    },
    login() {
      if (this.$route.path != '/login') {
        this.$router.push('/login');
      }
    },


    handleChange() {
      this.axios.get('http://localhost:19470/v1/workers/list')
          .then((response) => {
            if (response.data.code == 20000) {
              console.log(response.data.data)
              let butemp= response.data.data;
              for (let i=0;i<butemp.length;i++) {
                if (butemp[i].gender==true){
                  butemp[i].gender='男'
                }else{
                  butemp[i].gender='女'
                }
                if (butemp[i].findId==true){
                  butemp[i].findId='找活中';
                }else{
                  butemp[i].findId='已找到'
                }
              }
              this.business=butemp;
              this.businessTemp=this.business;
            }
          })
    }
  },
  mounted() {
    this.user=JSON.parse(localStorage.getItem('user'));

    this.handleChange();
    console.log(this.business)
  }
}
</script>

<style scoped>
.p_worker {
  /*margin-left: 20px;*/
  padding: 0px 10px 10px;
  font-size: 15px;
}

.type {
  width: 180px;
}
</style>
